import { LockType, SceneType } from "../CommonValue";
import GameUtils from "../GameUtils";
import { Global } from "../Global";

const { ccclass, property } = cc._decorator;

@ccclass
export default class RoomInfo extends cc.Component {
    @property(cc.EditBox)
    roomNameEdit: cc.EditBox = null;


    @property(cc.Toggle)
    isPrivateRoom: cc.Toggle = null;

    @property(cc.Toggle)
    isLockRoom: cc.Toggle = null;
    /**
     * “普通房间”按钮点击事件
     */
    OnCreatRoomBtn() {
        let customRoomProp = {
            roomType: Global.Inst().roomType
        }
        let roomConfig = {
            maxPlayers: 4,
            isPrivate: this.isPrivateRoom.isChecked ? LockType.Locked : LockType.UnLocked,
            roomName: this.roomNameEdit.string,
            roomType: 1 + "",
            matchParams: {
                'matchRule': Global.Inst().matchRule,
                'matchRule2': Global.Inst().matchRule,
            },
            customRoomProperties: JSON.stringify(customRoomProp),
            isLock: this.isLockRoom.isChecked ? LockType.Locked : LockType.UnLocked
        }
        Global.Inst().CreateRoom(roomConfig);
    }

    OnCancleBtnClick() {
        cc.director.loadScene(SceneType.MATCH);
    }




}
